
#ifndef _IREADER_H_
#define _IREADER_H_

#include <BMap>
#include <BStream>
#include <BNode>
#include <BLight>
#include <BCamera>
#include <BScene>
#include <BMesh>
#include <BGeometry>
#include <BMesh>
#include <BCone>
#include <BCube>
#include <BCylinder>
#include <BSphere>
#include <BTorus>
#include <BSurface>

#include <BImage>
#include <BFont>
#include <BDisplay>
#include <BMaterial>
#include <BTexture>
#include <BProgram>

#include <BWidget>
#include <BLayout>
#include <BButton>
#include <BSlider>
#include <BScrollArea>
#include <BComboBox>
#include <BCheckBox>
#include <BSpinBox>
#include <BLineEdit>
#include <BTextEdit>
#include <BTreeWidget>
#include <BListWidget>
#include <BTableWidget>
#include <BScrollBar>
#include <BScrollWidget>
#include <BLabel>
#include <BMenu>
#include <BMenuBar>
#include <BDialog>
#include <BGroupBox>
#include <BSplitter>
#include <BTabWidget>
#include <BViewer>
#include "IBlockSign.h"

#include <BReadWrite>

namespace BWE
{
	class IReader
	{
	public:
		IReader();
		~IReader();

		BObject* readObject(const BString& fileName);

	private://read
		bool readContent(BObject* object);

		bool readName(BObject* object);
		bool readEnable(BObject* object);
		bool readMask(BObject* object);
		bool readVisible(BObject* object);
		bool readBoundingBox(BObject* object);
		bool readMatrix(BObject* object);
		bool readRect(BObject* object);
		bool readSpace(BObject* object);
		bool readRowCount(BObject* object);
		bool readColumnCount(BObject* object);
		bool readRow(BObject* object);
		bool readColumn(BObject* object);
		bool readVertices(BObject* object);
		bool readNormals(BObject* object);
		bool readTexCoords(BObject* object);
		bool readFaces(BObject* object);
		bool readAmbient(BObject* object);
		bool readDiffuse(BObject* object);
		bool readSpecular(BObject* object);
		bool readEmission(BObject* object);
		bool readShininess(BObject* object);
		bool readAttenuation(BObject* object);
		bool readAttenuation2(BObject* object);
		bool readPosition(BObject* object);
		bool readCenter(BObject* object);
		bool readUp(BObject* object);
		bool readBlend(BObject* object);
		bool readBlendColor(BObject* object);
		bool readFilter(BObject* object);
		bool readWrap(BObject* object);
		bool readMipmap(BObject* object);
		bool readFileName(BObject* object);
		bool readFormat(BObject* object);
		bool readSize(BObject* object);
		bool readPixels(BObject* object);
		bool readTitle(BObject* object);
		bool readTip(BObject* object);
		bool readModal(BObject* object);
		bool readPos(BObject* object);
		bool readMinSize(BObject* object);
		bool readMaxSize(BObject* object);
		bool readStretch(BObject* object);
		bool readSizePolicy(BObject* object);
		bool readBorder(BObject* object);
		bool readPerch(BObject* object);
		bool readMargin(BObject* object);
		bool readLighting(BObject* object);
		bool readDepthTest(BObject* object);
		bool readLineSmooth(BObject* object);
		bool readLineWidth(BObject* object);
		bool readPointSmooth(BObject* object);
		bool readPointSize(BObject* object);
		bool readPolygonMode(BObject* object);
		bool readCullBack(BObject* object);
		bool readBaseSize(BObject* object);
		bool readPixelSize(BObject* object);
		bool readColor(BObject* object);

		BObject* readNode(BObject* object);
		BObject* readScene(BObject* object);
		BObject* readLight(BObject* object);
		BObject* readCamera(BObject* object);

		BObject* readMaterial(BObject* object);
		BObject* readTexture(BObject* object);
		BObject* readProgram(BObject* object);
		BObject* readImage(BObject* object);
		BObject* readPixmap(BObject* object);
		BObject* readBitmap(BObject* object);
		BObject* readState(BObject* object);
		BObject* readFont(BObject* object);
		BObject* readCursor(BObject* object);
		BObject* readPalette(BObject* object);

		BObject* readBillBoard(BObject* object);
		BObject* readText(BObject* object);
		BObject* readMesh(BObject* object);
		BObject* readGeometry(BObject* object);
		BObject* readCone(BObject* object);
		BObject* readCube(BObject* object);
		BObject* readCylinder(BObject* object);
		BObject* readSphere(BObject* object);
		BObject* readTorus(BObject* object);
		BObject* readSurface(BObject* object);
		BObject* readTerrain(BObject* object);

		BObject* readWidget(BObject* object);
		BObject* readButton(BObject* object);
		BObject* readSlider(BObject* object);
		BObject* readComboBox(BObject* object);
		BObject* readCheckBox(BObject* object);
		BObject* readSpinBox(BObject* object);
		BObject* readLineEdit(BObject* object);
		BObject* readTextEdit(BObject* object);
		BObject* readTreeWidget(BObject* object);
		BObject* readListWidget(BObject* object);
		BObject* readTableWidget(BObject* object);
		BObject* readScrollBar(BObject* object);
		BObject* readScrollWidget(BObject* object);
		BObject* readLabel(BObject* object);
		BObject* readMenu(BObject* object);
		BObject* readMenuBar(BObject* object);
		BObject* readDialog(BObject* object);
		BObject* readGroupBox(BObject* object);
		BObject* readSplitter(BObject* object);
		BObject* readTabWidget(BObject* object);
		BObject* readViewer(BObject* object);
		BObject* readLayout(BObject* object);
		BObject* readSpring(BObject* object);

	private:
		typedef bool(IReader::*ReadValue)(BObject* object);
		typedef BObject*(IReader::*Read)(BObject* object);
		BMap<int, ReadValue>	readValueMap;
		BMap<int, Read>			readMap;

		BMap<int, BString>		textMap;
		BMap<BString, int>		signMap;

		BStream*		stream;
		Block			block;
		BList<Block>	stack;
	};
}

#endif